package com.base.io_test;

import java.io.*;

/**
 * create by yongli on 2019-08-26 22:53
 */

public class FileO {
    public static void main(String[] args) throws Exception {
      read();
    }

    public static FileInputStream testString() throws Exception {

        String path = "/Users/yongli/word.txt";
        File file = new File(path);
        FileInputStream fis = new FileInputStream(file);
        //byte[] bytes = new byte[fis.available()];
        //fis.read(bytes);
        file.delete();
        Thread.sleep(2000);
        return fis;
    }
    public static void stream(InputStream is) throws IOException{
        InputStreamReader isr = new InputStreamReader(is,"UTF-8");
        StringBuffer sb= new StringBuffer();
        char[] buf =new char[1024];
        while (isr.read(buf) > 0){
            sb.append(buf);
        }
        System.out.println(new String(sb));
    }
    public static void test2(){

    }

    public static void read() throws Exception {

        String path = "/Users/yongli/1230.txt";
        File file = new File(path);
        FileInputStream fis = new FileInputStream(file);
        byte[] bytes = new byte[fis.available()];
        fis.read(bytes);
        // 解压时选择utf-16
        String content = new String(bytes,"UTF-16");
        System.out.println(content);
        return ;
    }


}
